<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <%--<meta http-equiv="refresh" content="1">--%>
    <title>js表单处理</title>
    <script>
        function myDate() {
            var date=new Date();
            var year=date.getFullYear();
            var month=date.getMonth()+1;
            var day=date.getDate();
            var hour=date.getHours();
            var minutes=date.getMinutes();
            var s=date.getSeconds();
            var hello="你好";
            if (month >= 1 && month <= 9) {
                month = "0" + month;
            }
            if (day >= 0 && day <= 9) {
                day = "0" + day;
            }
            if (hour>=6&&hour<12){
                hello="上午好！";
            }else if(hour>=12&&hour<18){
                hello="下午好！";
            }else if(hour>=18&&hour<24){
                hello="晚上好！";
            }else {
                hello="凌晨好！";
            }
            //document.write(year+"年"+month+"月"+day+"日"+" "+hour+":"+minutes+":"+s+" "+hello);
            document.getElementById("time").innerHTML=year+"年"+month+"月"+day+"日"+" "+hour+":"+minutes+":"+s+" "+hello;
        }

    </script>
</head>
<body>
<div style="margin: 0 auto;text-align: center">
    <h2>现在时间：</h2>
    <p id="time"></p>
<script>
    window.setInterval(function () {myDate()},1000);
    window.setTimeout(function() {window.location.href="http://www.163.com";},3000);
</script>
</div>
</body>

</html>
